<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<table id="propertyData"></table>  
<div id="propertyGrid_bar" style="padding:5px;height:auto; display: none">
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="appendProperty()">添加</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="editProperty()">编辑</a>
</div>
<input id="idValue" type="hidden"/>

<script type="text/javascript">
//获取左侧树中选择的节点id   
var nodeId=$('#class-tree').tree('getSelected').id;
$("#idValue").val(nodeId);//将id设置到隐藏域
 var  userObj=$('#propertyData').datagrid({
			singleSelect:true,
			url:'property/findPropertyById/'+nodeId,
			striped:true,
			loadMsg:"正在加载中...",
			remoteSort:false,
			fit:true,
			toolbar:"#propertyGrid_bar",
			columns:[[
			  		{field:'gpId',sortable:true,align:'center',checkbox:true},
			  		{field:'cId',title:'商品类目ID',width:100,align:'center'},
			  		{field:'cName',title:'商品类目名',width:100,align:'center'},
			  		{field:'gpParamData',title:'属性名',width:300,align:'center',},
			  		{field:'gpCreateTime',title:'创建时间',width:150,align:'center',
			  			formatter: function(value,row,index){
							return getDate(row.gpCreateTime.toString());
			  			}		
			  		},
			  		{field:'gpUpdateTime',title:'更新时间',width:150,align:'center',
			  			formatter: function(value,row,index){
			  				if(row.gpUpdateTime!=""&&row.gpUpdateTime!=undefined){
			  					return getDate(row.gpUpdateTime.toString());
			  				}
							
			  			}		
			  		}]]
			  		
			
		}); 
 
 function appendProperty(){
	 if($('#propertyData').datagrid('getRows').length>0){
		 $.messager.alert('提示','属性已存在,请编辑即可!','info');
	 }else{
		 commenUtil.createWindow({
			 			id:nodeId,
			 			title:'添加',
			     		url : "back/goods-property-add",
			     	})
	 }
 
 }
 function editProperty(){
	 if($('#propertyData').datagrid('getRows').length==0){
		 $.messager.alert('提示','请先添加属性数据!','info');
	 }else{
		 commenUtil.createWindow({
			 			id:nodeId,
			 			title:'修改',
			     		url : "back/goods-property-edit",
			     	})
	 }
 }
 
</script>